﻿/*
 * ********************************************************************************************************************
 *
 *               iFHS7.
 *              ;BBMBMBMc                  rZMBMBR              BMB
 *              MBEr:;PBM,               7MBMMEOBB:             BBB                       RBW
 *     XK:      BO     SB.     :SZ       MBM.       c;;     ir  BBM :FFr       :SSF:    ;xBMB:r   iuGXv.    i:. iF2;
 *     DBBM0r.  :D     S7   ;XMBMB       GMBMu.     MBM:   BMB  MBMBBBMBMS   WMBMBMBBK  MBMBMBM  BMBRBMBW  .MBMBMBMBB
 *      :JMRMMD  ..    ,  1MMRM1;         ;MBMBBR:   MBM  ;MB:  BMB:   MBM. RMBr   sBMH   BM0         UMB,  BMB.  KMBv
 *     ;.   XOW  B1; :uM: 1RE,   i           .2BMBs  rMB. MBO   MBO    JMB; MBB     MBM   BBS    7MBMBOBM:  MBW   :BMc
 *     OBRJ.SEE  MRDOWOR, 3DE:7OBM       .     ;BMB   RMR7BM    BMB    MBB. BMB    ,BMR  .BBZ   MMB   rMB,  BMM   rMB7
 *     :FBRO0D0  RKXSXPR. JOKOOMPi       BMBSSWBMB;    BMBB:    MBMB0ZMBMS  .BMBOXRBMB    MBMDE RBM2;SMBM;  MBB   xBM2
 *         iZGE  O0SHSPO. uGZ7.          sBMBMBDL      :BMO     OZu:BMBK,     rRBMB0;     ,EBMB  xBMBr:ER.  RDU   :OO;
 *     ,BZ, 1D0  RPSFHXR. xWZ .SMr                  . .BBB
 *      :0BMRDG  RESSSKR. 2WOMBW;                   BMBMR
 *         i0BM: SWKHKGO  MBDv
 *           .UB  OOGDM. MK,                                          Copyright (c) 2015-2019.  斯伯坦机器人
 *              ,  XMW  ..
 *                  r                                                                     All rights reserved.
 *
 * ********************************************************************************************************************
 */

using Fluent;
using System.Windows;
using System.Windows.Input;

namespace MongoPI
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : RibbonWindow
    {
        /// <summary>
        /// 主窗口构造函数
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            // 绑定命令
            BindCommands();
            Explorer.DocumentPane = DocumentPane;

            // DockManager.Theme = new GenericTheme();

            return;
        } // Function MainWindow()

        /// <summary>
        /// 绑定命令
        /// </summary>
        private void BindCommands()
        {
            /// 绑定添加数据库命令
            CommandBinding DatabaseAddBinding = new CommandBinding(DatabaseCommands.Add);
            DatabaseAddBinding.Executed += Explorer.CmdDatabaseAdd_Executed;
            DatabaseAddBinding.CanExecute += Explorer.CmdDatabaseAdd_CanExecute;
            CommandBindings.Add(DatabaseAddBinding);

            /// 绑定删除数据库命令
            CommandBinding DatabaseDropBinding = new CommandBinding(DatabaseCommands.Drop);
            DatabaseDropBinding.Executed += Explorer.CmdDatabaseDrop_Executed;
            DatabaseDropBinding.CanExecute += Explorer.CmdDatabaseDrop_CanExecute;
            CommandBindings.Add(DatabaseDropBinding);

            /// 绑定添加集合命令
            CommandBinding CollectionAddBinding = new CommandBinding(CollectionCommands.Add);
            CollectionAddBinding.Executed += Explorer.CmdCollectionAdd_Executed;
            CollectionAddBinding.CanExecute += Explorer.CmdCollectionAdd_CanExecute;
            CommandBindings.Add(CollectionAddBinding);

            /// 绑定删除集合命令
            CommandBinding CollectionDropBinding = new CommandBinding(CollectionCommands.Drop);
            CollectionDropBinding.Executed += Explorer.CmdCollectionDrop_Executed;
            CollectionDropBinding.CanExecute += Explorer.CmdCollectionDrop_CanExecute;
            CommandBindings.Add(CollectionDropBinding);

            /// 绑定删除集合命令
            CommandBinding CollectionCleanBinding = new CommandBinding(CollectionCommands.Clear);
            CollectionCleanBinding.Executed += Explorer.CmdCollectionClear_Executed;
            CollectionCleanBinding.CanExecute += Explorer.CmdCollectionClear_CanExecute;
            CommandBindings.Add(CollectionCleanBinding);

            /// 绑定用户管理命令
            CommandBinding UserManageBinding = new CommandBinding(UserCommands.Manage);
            UserManageBinding.Executed += Explorer.CmdUserManage_Executed;
            UserManageBinding.CanExecute += Explorer.CmdUserManage_CanExecute;
            CommandBindings.Add(UserManageBinding);

            /// 绑定角色管理命令
            CommandBinding RoleManageBinding = new CommandBinding(RoleCommands.Manage);
            RoleManageBinding.Executed += Explorer.CmdRoleManage_Executed;
            RoleManageBinding.CanExecute += Explorer.CmdRoleManage_CanExecute;
            CommandBindings.Add(RoleManageBinding);
            return;
        } // Function BindCommands()

        /// <summary>
        /// 用户执行“关于”命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdAbout_Click(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            AboutDialog dlg = new AboutDialog();
            dlg.ShowDialog();
            return;
        } // CmdExit_Click()

        /// <summary>
        /// 用户执行“退出”命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdExit_Click(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            Close();
            return;
        } // CmdExit_Click()

        /// <summary>
        /// 用户执行“帮助”命令
        /// </summary>
        /// <param name="sender">事件的发送者</param>
        /// <param name="e">事件参数</param>
        private void CmdHelp_Click(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("CmdHelp_Click");
            return;
        } // CmdExit_Click()
    } // Class MainWindow
} // Namespace MongoPI
